import socket


def main():
    tcp_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    tcp_server.bind(('192.168.239.1', 7890))
    tcp_server.listen(128)
    print(tcp_server)
    while True:
        client_socket, client_addr = tcp_server.accept()
        print(client_addr)
        while True:
            recv_data = client_socket.recv(1024)
            print(1)
            if recv_data:
                print(1)
                print(recv_data.decode("gbk"))
                client_socket.send("收到了".encode("gbk"))
            else:
                print("服务完毕")
                break
        client_socket.close()


if __name__ == "__main__":
    main()
